===================================
 SGB2 Border Injector
   Author:     blizzz
   Version:    1.01
   Date:       26 January 2022
===================================

SGB2 Border Injector is a Windows app that lets you inject custom
borders into the Super Game Boy 2 rom file. Custom borders can replace
borders 3 to 9 of the SGB2. The special colors of the GB Pocket border
as well as the old SGB1 borders are still available.

All borders from SGB enhanced games are supported, as well as custom
images that follow the requirements explained under "Image requirements"
further below.
You can find over 800 compatible borders on vgmuseum.com:
http://www.vgmuseum.com/features/sgb/

This app is compatible with roms that were already edited by SGB
Settings Editor. To display custom borders correctly in that app you
need version 1.4.
Edited rom files can be used on the SD2SNES / FXPAK Pro. Rename them to
sgb2_snes.bin.

Checksum of unmodified SGB2 rom file:
Super Game Boy 2 (Japan).sfc             524,288 bytes  CB176E45

Super Game Boy 1 roms are not supported.


How to use
------------------------------------------------------------------------
Select your Super Game Boy 2 rom file, your custom border image (either
in png or bmp format) and the border slot you want to replace and hit
Inject.

Depending on the size of the resulting tileset not all slots are
available. The app will tell you if your image doesn't fit in the slot.
Slot 3 is the smallest and can only be used with images that compress
well. Most images should fit in slots 4 to 9.


Image requirements
------------------------------------------------------------------------
Size: 256 x 224 pixels
File format: PNG or BMP (other lossless formats might also work)
Colors: Maximum of 45 unique colors in three 15 color palettes. Each
8 x 8 pixel tile can only use colors from one 15 color palettes.

Images with more colors will be automatically converted to fit the SNES
restrictions. Enable the dithering option for images with a high color
depth (like photos). Pixel art images will mostly look better without
dithering.

The app will automatically generate palettes for you, but you can
provide your own palettes by putting them in a file named palettes.bin
next to the executable.
Palettes.bin is a 96 byte binary file that contains 3 SNES style
palettes. (2 byte GBR value in little endian order for each of the 48
colors, same as in CGRAM. The first color in each palette is ignored,
since it's rendered transparent)


Tips for creating border images
------------------------------------------------------------------------
Create one layer for each of the three 15 color palettes you're working
with and enable an 8 x 8 pixel grid overlay in your paint program. Use
only the colors from one palette in each 8 x 8 pixel tile.

If you're converting an existing image, try to divide the tiles manually
by color into three layers. Then you can lower the amount of colors per
layer to 15 individually. This will generally result in better picture
quality than the automatic color reduction.

Check out Aseprite if you're looking for a paint program.


Icon requirements
------------------------------------------------------------------------
You can create your own menu icons. Icons need to be in .png or .bmp
format and have a resolution of 10 x 14 pixels for just the art, or
16 x 16 pixels with border.

Icons can only use the following colors:
#000000, #ffffff, #efcebd, #ff8c31, #cecece, #a58c5a, #ffff6b, #6bff6b,
#ff9494, #b5b5ff, #735a21, #bd8442, #cea573, #c6945a, #e7d6c6

SGB_Icon_Active.pal and SGB_Icon_Inactive.pal are Aseprite palette
files.


Requirements
------------------------------------------------------------------------
Windows 7 SP1 or newer with .NET Framework 4.7.2.


Credits
------------------------------------------------------------------------
blizzz - Programming, Hacking
flamepanther - Bonus icons

Color reduction and dithering:
Smart K8 - A Simple - Yet Quite Powerful - Palette Quantizer in C#
  (Version 5.0)
Xiaolin Wu - WuColorQuantizer


Contact
------------------------------------------------------------------------
@blizzzilla on Twitter

RHDN Forums:
https://www.romhacking.net/forum/index.php?action=profile;u=71746

Bugs and feature requests can be submitted on GitHub:
https://github.com/blzla/SGB2-Border-Injector/issues


Version History
------------------------------------------------------------------------
1.01 - 26 January 2022
Fixes a bug where the tileset size for compressed border slots wasn't
checked correctly

1.0 - 06 January 2022 (Testing - 19 December 2021)
Increased maximum tileset size for SGB2 slots
Added support for SGB1 slots (compressed)
Screensaver animations of unmodified borders are no longer deactivated
Added automatic color reduction and dithering for images with too many
colors

0.91 - 21 November 2021
Added option to customize menu icon

0.9 - 04 November 2021
Initial Release of SGB2 Border Injector
